/* eslint-disable strict */
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  const jwt = app.middleware.jwt(app.config.jwt);
  // 登录相关
  router.post('/api/login', controller.login.login);
  router.post('/api/logout', controller.login.logout);
  router.get('/api/code', controller.login.getPhoneCode);

  // 当前用户
  router.get('/api/currentUser', jwt, controller.user.currentUser);

  // 人力资源管理
  router.get('/api/hr/personnel', jwt, controller.personnel.index);
  router.post('/api/hr/personnel', jwt, controller.personnel.create);
  router.put('/api/hr/personnel/:id', jwt, controller.personnel.update);
  router.delete('/api/hr/personnel/:id', jwt, controller.personnel.destroy);
  router.get('/api/hr/personnel/detail', jwt, controller.personnel.getPersonnelById);

  router.get('/api/hr/education', jwt, controller.education.index);
  router.post('/api/hr/education', jwt, controller.education.create);
  router.put('/api/hr/education/:personnels_id', jwt, controller.education.update);
  router.delete('/api/hr/education/:personnels_id', jwt, controller.education.destroy);

  router.post('/api/hr/qualification/create', jwt, controller.qualification.createQualification);
  router.post('/api/hr/qualification/query', jwt, controller.qualification.queryQualification);
  router.get('/api/hr/qualification/detail', jwt, controller.qualification.getQualificationByPid);

  // 业务代码
  router.get('/api/hr/business', jwt, controller.business.index);
  router.delete('/api/hr/business/:id', jwt, controller.business.destroy);
  router.get('/api/hr/business/download', jwt, controller.business.download);

  // 培训登记
  router.post('/api/hr/training', jwt, controller.training.create);
  router.get('/api/hr/training', jwt, controller.training.index);
  router.delete('/api/hr/training/:personnels_id', jwt, controller.training.delete);
  router.put('/api/hr/training/:personnels_id', jwt, controller.training.update);
  router.get('/api/hr/training/download', jwt, controller.training.download);
  // 工作信息登记
  router.post('/api/hr/work', jwt, controller.work.create);
  router.get('/api/hr/work', jwt, controller.work.index);
  router.delete('/api/hr/work/:personnels_id', jwt, controller.work.delete);
  router.put('/api/hr/work/:personnels_id', jwt, controller.work.update);
  router.get('/api/hr/work/download', jwt, controller.work.download);

  // 请假登记
  router.post('/api/hr/absence', jwt, controller.absence.create);
  router.get('/api/hr/absence', jwt, controller.absence.index);
  router.delete('/api/hr/absence/:id', jwt, controller.absence.delete);
  router.put('/api/hr/absence/:id', jwt, controller.absence.update);
  router.get('/api/hr/absence/download', jwt, controller.absence.download);

  // 快递管理
  router.get('/api/delivery', jwt, controller.delivery.index);
  router.get('/api/delivery/:id', jwt, controller.delivery.show);
  router.post('/api/delivery', jwt, controller.delivery.create);
  router.put('/api/delivery/:id', jwt, controller.delivery.update);
  router.delete('/api/delivery/:id', jwt, controller.delivery.destroy);

  // 合同管理
  router.get('/api/contract', jwt, controller.contract.index);
  router.post('/api/contract', jwt, controller.contract.create);
  router.put('/api/contract/:id', jwt, controller.contract.update);
  router.delete('/api/contract/:id', jwt, controller.contract.destroy);
  router.get('/api/contract/download', jwt, controller.contract.download);

  // 财务管理
  router.get('/api/finance', jwt, controller.finance.index);
  router.post('/api/finance', jwt, controller.finance.create);
  router.put('/api/finance/:id', jwt, controller.finance.update);
  router.delete('/api/finance/:id', jwt, controller.finance.destroy);
  router.get('/api/finance/download', jwt, controller.finance.download);

  // 库房管理
  router.get('/api/storehouse', jwt, controller.storehouse.index);
  router.post('/api/storehouse', jwt, controller.storehouse.create);
  router.put('/api/storehouse/:id', jwt, controller.storehouse.update);
  router.delete('/api/storehouse/:id', jwt, controller.storehouse.destroy);
};
